package com.example.wlf.gamerecorder;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.tencent.mm.opensdk.openapi.IWXAPI;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;


/**
 * @author wlf
 * 全局变量
 *  Created by wlf on 2018/09/04.
 */
public class Constants {
    /**
     * 创建全局的appId
     */
    public static final String APP_ID = "wx_*******"; //替换为申请到的app id

    public static IWXAPI wx_api; //全局的微信api对象

    public static void stringToTime(String string,String format){
        if (format == null || format.isEmpty()) {
            format = "mm:ss";
        }
        string = "12:00";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date date = null;
        try {
            date = sdf.parse(string);
            //SimpleDateFormat中的parse方法可以
            //把String型的字符串转换成特定格式的date类型
        } catch (ParseException e) {
            System.out.println(e.getMessage());
        }
        Log.d("willianf",date.toString());
       // Log.d("willianf",date.getTime());
    }
    public static boolean countDownRule(TextView textview,int minute, int second){
        //second = 0;
        if (minute == 0) {
            if (second == 0) {
                textview.setText("00:00");
                return false;

            } else {
                //second--;
                if (second >= 10) {
                    textview.setText("0" + minute + ":" + second);
                } else {
                    textview.setText("0" + minute + ":0" + second);
                }
            }
        } else {
            if (second == 0) {
                //second = 59;
                //minute--;
                if (minute >= 10) {
                    textview.setText(minute + ":" + second);
                } else {
                    textview.setText("0" + minute + ":" + second);
                }
            } else {
                //second--;
                if (second >= 10) {
                    if (minute >= 10) {
                        textview.setText(minute + ":" + second);
                    } else {
                        textview.setText("0" + minute + ":" + second);
                    }
                } else {
                    if (minute >= 10) {
                        textview.setText(minute + ":0" + second);
                    } else {
                        textview.setText("0" + minute + ":0" + second);
                    }
                }
            }
        }
        return true;
    }

    /**
     *
     * @param activity
     * @param string

    public void showToast(Activity activity, String string){
        Toast toast = new Toast(activity);
        Toast toast = new Toast.makeText(activity,"da",Toast.LENGTH_SHORT);
        toast.show();
    }
     */
}


